import 'package:flutter/material.dart';
import 'package:flutter_base/src/config/app_colors.dart';
import 'package:flutter_base/src/utils/loading_utils.dart';

class LoadingDialogWidget extends StatefulWidget {
  final String message;

  const LoadingDialogWidget({super.key, required this.message});

  @override
  State<LoadingDialogWidget> createState() => _LoadingDialogWidgetState();
}

class _LoadingDialogWidgetState extends State<LoadingDialogWidget> {
  @override
  void initState() {
    super.initState();
    WidgetsBinding.instance.addPostFrameCallback((_) {
      LoadingUtils.dialogAlreadyShow();
    });
  }

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      height: 140,
      child: Padding(
        padding: const EdgeInsets.all(16),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            SizedBox(
              width: 48,
              height: 48,
              child: CircularProgressIndicator(color: AppColors.of(context).primaryColor),
            ), // 显示加载指示器
            const SizedBox(height: 16),
            Text(widget.message, style: TextStyle(color: AppColors.of(context).textColors3, fontSize: 16)),
          ],
        ),
      ),
    );
  }
}
